fix: Disabled Appearance="Primary" button renders white text on light background#1701
Open
fix: Disabled Appearance="Primary" button renders white text on light background#1701
Appearance="Primary" button renders white text on light background#1701Conversation
Agent-Logs-Url: https://github.com/lepoco/wpfui/sessions/f0a2c2e9-811c-4b3a-b8b2-6bebe5eede48 Co-authored-by: pomianowski <13592821+pomianowski@users.noreply.github.com>
Copilot
AI
changed the title
fix(controls): [WIP] Fix white text rendering on disabled primary button
fix: Disabled Apr 30, 2026
Appearance="Primary" button renders white text on light background
dkuaf
reviewed
Apr 30, 2026
| <!-- DISABLED - must be last to override Appearance trigger foreground --> | ||
| <Trigger Property="IsEnabled" Value="False"> | ||
| <Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> | ||
| </Trigger> |
Contributor
There was a problem hiding this comment.
i think it should be better to move the Appearance triggers to inside the ControlTemplate.Triggers and position them before the existing triggers, i tested it and it works nicely. @pomianowski can i make another PR?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 4.2.1, a
ui:ButtonwithAppearance="Primary" IsEnabled="False"renders white text on the grey disabled background — invisible in light theme.Pull request type
What is the current behavior?
WPF Style triggers have higher precedence than ControlTemplate triggers for the same dependency property. The
Appearance="Primary"Style trigger setsForeground = AccentButtonForeground(white). When the button is also disabled, the ControlTemplate'sIsEnabled=Falsetrigger attempts to setForeground = ButtonForegroundDisabled, but is overridden by the Style-level Appearance trigger — leaving white text on a grey disabled background.What is the new behavior?
IsEnabled=Falsetrigger is added at the end ofStyle.TriggersinDefaultUiButtonStyle, after all Appearance triggers.ButtonForegroundDisabledalways overrides the Appearance foreground when the button is disabled — for all appearances.Other information
Regression introduced by #1680, which moved the disabled foreground setter from per-element
TargetNamesetters (insideControlTemplate.Triggers) to a Style-levelForegroundsetter — exposing the trigger precedence conflict with Appearance triggers.